#pragma once
#include <iostream>
#include <fstream>
#include <string>
#include "Log.hpp"

using namespace LogModule;


class Util
{
public:
    static bool tools(std::string path, std::string& result)
    {
        //打开文件若文件不存在会自动创建
        std::ifstream file(path);
        //判断文件是否打开成功
        if(!file.is_open())
        {
            return false;
        }
        std::string line;
        while(std::getline(file, line))
        {
            result += line;
        }
        return true;
    }

    static bool ReadOneLine(std::string& str, std::string& out, const std::string& sep)
    {
        auto pos = str.find(sep);
        if(pos == std::string::npos)
        {
            LOG(LogLevel::DEBUG) << "find error";
            return false;
        }
        out = str.substr(0,pos);
        str.erase(0, pos + sep.size());
        return true;
    }
};